package com.example.express.model;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Objects;

@Entity
public class PackageRoute {
    private int sn;
    private double x;
    private double y;
    private Timestamp tm;
    private TransPackage transPackage;

    @Id
    @Column(name = "SN")
    public int getSn() {
        return sn;
    }

    public void setSn(int sn) {
        this.sn = sn;
    }

    @Basic
    @Column(name = "x")
    public double getX() {
        return x;
    }

    public void setX(double x) {
        this.x = x;
    }

    @Basic
    @Column(name = "y")
    public double getY() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }

    @Basic
    @Column(name = "tm")
    public Timestamp getTm() {
        return tm;
    }

    public void setTm(Timestamp tm) {
        this.tm = tm;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PackageRoute that = (PackageRoute) o;
        return sn == that.sn &&
                Double.compare(that.x, x) == 0 &&
                Double.compare(that.y, y) == 0 &&
                Objects.equals(tm, that.tm);
    }

    @Override
    public int hashCode() {
        return Objects.hash(sn, x, y, tm);
    }

    @ManyToOne
    @JoinColumn(name = "PackageID", referencedColumnName = "ID", nullable = false)
    public TransPackage getTransPackage() {
        return transPackage;
    }

    public void setTransPackage(TransPackage transPackage) {
        this.transPackage = transPackage;
    }
}
